/**
 * Copyright (C) 2017-2018 pinganfang, Inc. All Rights Reserved.
 */
package com.pingan.haofang.searchcloud.index.constants;

import com.pingan.haofang.framework.common.functional.lang.control.base.annotation.Value;

/**
 * @author huhailiang937
 * @date 2017年5月11日上午11:05:50
 * @since 1.0.0
 */
public enum IndexDatasourceStatus {

    
    NORMAL(0, "normal"), DISABLE(1, "disable");

    private Integer id;
    private String desc;  
    
    private IndexDatasourceStatus(Integer id, String desc) {
        this.id = id;
        this.desc = desc;
    }

    public static IndexDatasourceStatus get(Number id) {
        if (null == id) {
            return null;
        }
        for (IndexDatasourceStatus temp : IndexDatasourceStatus.values()) {
            if (temp.getId().equals(id.intValue())) {
                return temp;
            }
        }
        return null;
    }

    public static IndexDatasourceStatus getValueByName(String name) {
        if (null == name) {
            return null;
        }
        for (IndexDatasourceStatus temp : IndexDatasourceStatus.values()) {
            if (temp.getDesc().equals(name)) {
                return temp;
            }
        }
        return null;
    }

    /**
     * @return the id
     */
    @Value
    public Integer getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * @return the desc
     */
    public String getDesc() {
        return desc;
    }

    /**
     * @param desc
     *            the desc to set
     */
    public void setDesc(String desc) {
        this.desc = desc;
    }
}